package club.babyf.nativeai.controller;

import club.babyf.nativeai.service.IChatService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

/**
 * NativeAiController.
 *
 * @author zhanglei.
 * @date 2025/2/18 16:49.
 * @description 原生AI控制器.
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/native-ai/message")
public class NativeAiController {

    private final IChatService chatService;

    /**
     * 问答
     *
     * @param authorization authorization
     * @param isCusFunCall  是否开启自定义函数调用
     * @param body          请求参数
     * @return 问答结果
     */
    @PostMapping(value = "/chat", produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_EVENT_STREAM_VALUE})
    public Object chat(@RequestHeader(value = "Authorization") String authorization, @RequestParam(value = "isCusFunCall", defaultValue = "false") Boolean isCusFunCall, @RequestBody String body) {
        return chatService.chat(authorization, isCusFunCall, body);
    }

}
